package cn.hl.feign;

import cn.hl.domain.MovieTicket;
import cn.hl.dto.MovieTicketDto;
import cn.hl.enums.GlobalExceptionCode;
import cn.hl.query.MovieTicketQuery;
import cn.hl.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MovieServerFallbackFactory implements FallbackFactory<MovieServer> {
    @Override
    public MovieServer create(Throwable throwable) {
        return new MovieServer() {
            @Override
            public JSONResult saveOrUpdate(MovieTicket movieTicket) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult delete(Long id) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult get(Long id) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult list() {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult page(MovieTicketQuery query) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult buyMovieTicketById(MovieTicketDto movieTicketDto) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult findMovieTicketByUserId(Long id) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult watchMovieById(MovieTicketDto movieTicketDto) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

            @Override
            public JSONResult sendMovieTicket(Long id) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE);
            }

        };
    }
}
